﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TextDungeon
{
    class World
    {
        Cell[,] cells;
        GUI gui = new GUI();
        
        public World(int width, int height) 
        {

            CellType ct = CellType.Other;
            var rand = new Random();
            cells = new Cell[height, width];
            for (int y = 0; y < height; y++)
            {

                for (int x = 0; x < width; x++)
                {
                    cells[y, x] = new Cell(CellType.Other);
                }
                 
            }
        }
        public Cell CurrentCell(Position wp)
        {
            return cells[wp.Y, wp.X];
        }
        public List<Entity> RenderLevel(Position wp) //will render and return the level given by a world positoin
        {
            var color = ConsoleColor.White;
            //if (wp.X > cells.Length)
            //    wp.X = cells.Length;
            //if (wp.Y > cells.Rank)
            //    wp.Y = cells.Rank;

            var c = cells[wp.Y, wp.X];
            foreach (var e in c.walls)
            {
                gui.WriteAt(e.symbol, e.pos,color);
            }
            gui.WriteAt(String.Format("x:{0}:y:{1}", wp.X, wp.Y), new Position(100), ConsoleColor.Red);
            gui.WriteAt(c.ct.ToString(), new Position(100, 2), ConsoleColor.Blue);
            return c.walls;
        }
    }
}
